<template>
  <!--评分 所有投标人 打分 合计 -->
  <a-card :bordered="false">
    <a-tabs type="card" @change="e=>changeStep(e)">
      <a-tab-pane key="1" tab="综合指标">
      </a-tab-pane>
      <a-tab-pane key="2" tab="技术指标">
      </a-tab-pane>
    </a-tabs>
    <!-- table区域-begin -->
    <div>
      <a-table
        ref="table"
        size="middle"
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="false"
        :expandedRowKeys="expandedRowKeys"
        :defaultExpandAllRows="true"
      >
      </a-table>
    </div>
  </a-card>
</template>

<script>
import '@/assets/less/TableExpand.less'
import { getAction, postAction } from '@api/manage'

export default {
  name: 'PfTenderDetail',
  components: {},
  props: {
    bidSectionId:{},
    tenderId: {},
    realBusinessId: {}
  },
  data () {
    return {
      description: '评分明细',
      // 表头
      columns: [
        {
          title: ' ',
          align: 'left',
          dataIndex: 'name'
        },
        {
          title: '指标名称',
          align: 'left',
          dataIndex: 'indicatorName'
        },
        {
          title: '指标类型',
          align: 'left',
          dataIndex: 'indicatorType'
        },
        {
          title: '分值',
          align: 'left',
          dataIndex: 'score'
        },
        {
          title: '最小分值',
          align: 'left',
          dataIndex: 'scoreMin'
        },
        {
          title: '最大分值',
          align: 'left',
          dataIndex: 'scoreMax'
        },

        {
          title: '权重',
          align: 'left',
          dataIndex: 'weight'
        },

        {
          title: '评审说明',
          align: 'left',
          dataIndex: 'description'
        },
        {
          title: ' ',
          dataIndex: 'action',
          align: 'center',
          scopedSlots: { customRender: 'action' }
        }
      ],
      url: {
        // 查询投标人评分汇总合计
        queryTenderPfSum: '/exPingbiao/exPingbiaoExpertRecord/queryTenderPfSum'
      },
      dataSource: [],
      expandedRowKeys: [],
      businessType: '综合指标',
      expertList: [],
      businessId: null
    }
  },
  watch: {},
  created () {

  },
  mounted () {
  },
  computed: {},
  methods: {
    changeStep (e) {
      if (e == 1) {
        this.businessType = '综合指标'
      } else {
        this.businessType = '技术指标'
      }
      this.loadData()
    },
    /**
     * @param businessId
     * @param businessType 综合、技术
     */
    loadData (businessId) {
      if(businessId){
        this.businessId = businessId;
      }
      let params = {
        businessId: this.businessId,
        businessType: this.businessType,
        sectionId:this.bidSectionId
      }
      getAction(this.url.queryTenderPfSum, params)
        .then((res) => {
          if (res.success) {
            let result = res.result
            this.initExpandedRowKey(result)
            this.dataSource = result
          } else {
            this.$message.warning(res.message)
          }
        })
        .finally(() => {})
    },
    initExpandedRowKey (list) {
      list.forEach(item => {
        (item.scoreList || []).forEach(scoreItem => {
          let find = this.columns.find(e => e.dataIndex == scoreItem.id)
          if (!find) {
            this.columns.push({
              title: scoreItem.name,
              dataIndex: scoreItem.id
            })
          }
          item[scoreItem.id] = scoreItem.score
        })
        this.expandedRowKeys.push(item.id)
        if (item.children && item.children.length > 0) {
          this.initExpandedRowKey(item.children)
        }
      })
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>
